package com.foreknow.demo5;

public class Manager2 {
    //创建数组容器
    public static int[] sum(){
        int []container=new int[3];
        int [] array= {1,2,1};
        //基数和
        int sum1= 0;
        for (int i=0;i<array.length ;i++){
            if (i%2!=0){
                sum1=sum1+array[i];
            }
        }
        //偶数和
        int sum2= 0;
        for(int i=0;i<array.length ;i++) {
            if (i%2==0){
                sum2 = sum2 + array[i];
            }

        }
        //总和
        int sum3=0;

        for(int i=0;i<array.length ;i++) {
            sum3 = sum3 + array[i];
        }
        container[0]=sum1;
        container[1]=sum2;
        container[2]=sum3;

        return container;

    }

    public static void main(String[] args) {
        int [] array = {1,2,1};
      int[]con=  Manager2.sum();
      for (int i=0;i<con.length;i++){
          System.out.println(con[i]);
      }

    }

}
